package cn.itcast.producer;




import cn.itcast.service.cargo.ContractService;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.io.IOException;
import java.util.List;

public class TopicProducer {

    @Reference
    private static ContractService contractService;

    public static void main(String[] args) throws IOException {

        //1. 加载rabbitmq的核心配置文件
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath*:spring/applicationContext-*.xml");
        context.start();
        System.in.read();

        List<String> deliveryPeriodList = contractService.findAllDeliveryPeriod();
        System.out.println("========"+deliveryPeriodList);

        //2. 从spring容器中查找rabbittemplate对象
        //RabbitTemplate rabbitTemplate = (RabbitTemplate) context.getBean("rabbitTemplate");

        //3. 创建user对象，并且把user对象发送

        //ContractEmail contractEmail = new ContractEmail();
        //添加一个定时任务，查找交货期限，如果是还有3天就交货，就发送到rabbitmq上
        //convertAndSend(“交换机名字”,"路由key名字",发送的消息);
            /*ContractEmail contractEmail = new ContractEmail();
            contractEmail.setEmail(getLoginUser().getEmail());
            contractEmail.setContract(contract);
            rabbitTemplate.convertAndSend("email-exchange","contract.emailRemind",contractEmail);*/


        //context.close();
    }
}
